<?php
include('./includes/dbconnection.php'); // open db connection



$result = mysql_query("SELECT * FROM Assets ORDER BY Path") or die(mysql_error());
/*
while($row = mysql_fetch_array($result)){
    echo $row['Title']."\n";
}
*/
?>
<!--
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>


        <meta http-equiv="content-type" content="text/html; charset=utf-8">

        <style type="text/css">
            /*margin and padding on body element
            can introduce errors in determining
            element position and are not recommended;
            we turn them off as a foundation for YUI
            CSS treatments. */
            body {
                margin:0;
                padding:0;
            }
        </style>

        <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/container/assets/skins/sam/container.css">
        <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/fonts/fonts-min.css" />
        <link rel="stylesheet" href="http://yui.yahooapis.com/2.7.0/build/reset-fonts-grids/reset-fonts-grids.css" type="text/css">
        <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/2.7.0/build/treeview/assets/skins/sam/treeview.css" />
        <link rel="stylesheet" type="text/css" href="includes/folders.css" />

        <script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
        <script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/treeview/treeview-min.js"></script>
        <script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/container/container-min.js"></script>
        <script type="text/javascript" src="../jquery-1.3.2.js"></script>

        <style>
            #treeDiv1 {background: #fff; padding:1em;}
        </style>

-->

    <script type="text/javascript">

            //global variable to allow console inspection of tree:
    //        var tree;

            //anonymous function wraps the remainder of the logic:
            (function() {

                //function to initialize the tree:
                function treeInit() {
                    //    buildRandomTextNodeTree();
//                    tree = new YAHOO.widget.TreeView("treeDiv1");

                    // construct file tree...
                    // start with the pathNode being the tree root node.
                    // when different path encountered, create new node and
                    // attach nodes off of that
                    // Use PHP to generate the Javascript code to do this


<?php
$currPath="";
echo "tree.removeChildren(tree.getRoot());\n";
echo 'tree.singleNodeHighlight = true;'."\n";


echo "pathNode = tree.getRoot()\n";
while($row = mysql_fetch_array($result)){
    if($row['Path'] != $currPath){
        echo 'var pathNode = new YAHOO.widget.TextNode("';
        echo $row['Path'];
        echo "\", tree.getRoot(), false);\n";

        $currPath=$row['Path'];
    }

    echo "var myobj = { label:\"<a>".$row['Title']."</a>\" ";
    echo ", myNodeId: \"".$row['ID']."\"};\n";
    echo 'var myNode = new YAHOO.widget.TextNode(';
    echo "myobj";
    echo ', pathNode, false);'."\n";

}

 
?>

          
            $("#msg").ajaxError(function(event, request, settings){
                $(this).append("<li>Error requesting page " + settings.url + "</li>");
            });

            tree.draw();
        }
        //Add an onDOMReady handler to build the tree when the document is ready
      YAHOO.util.Event.onDOMReady(treeInit);

    })();

        </script>


<!--


    </head>


</html>

-->
